package com.jiangruan.javaproject.request.service;

import com.alibaba.fastjson.JSONObject;
import com.jiangruan.javaproject.Constants;
import com.jiangruan.javaproject.entity.HotVideo;
import com.jiangruan.javaproject.entity.HotVideoCommon;
import com.jiangruan.javaproject.request.HttpUtils;

import java.util.List;

/**
 * @author:liufukai
 * @email:1324963242@qq.com
 * @desc:
 * @datatime:2021/12/919:27
 */
public class HotVideoService {
    /**
     * 该方法用于获取热门数据，并将热门数据返回
     * @return
     */
    public List<HotVideo> getHotVideo(){
        String url= Constants.TRIP_URl+"?key="+Constants.TRIP_KEY+"&type=hot_video"+"&size=20";
        String result = HttpUtils.get(url);
        System.out.println(result);
        //json解析成类对象
        HotVideoCommon videoCommon= JSONObject.parseObject(result, HotVideoCommon.class);
        System.out.println(videoCommon.result.size());

        return videoCommon.result;
    }
}
